package com.example.controller;


import com.example.domain.TestDTO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

@RestController(value = "testController")
@RequestMapping("/test")
@Validated
public class TestController {


    @GetMapping("/num/{num}")
    public Integer detail(@PathVariable("num") @Min(1) @Max(10) Integer num){
        return num * num;
    }

    @PostMapping("/test-validation")
    public void testValidation(@RequestBody @Validated TestDTO testDTO){
        System.out.printf("testDTO.password:" + testDTO.getPassword());
    }
}
